index.html.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <!-- 头部 -->
  3. <templateHead v-if="skinId<=4"></templateHead>
  4. <!-- 皮肤5头部 -->
  5. <templateHead5 v-if="skinId==5"></templateHead5>
  6. <!-- 皮肤6头部 -->
  7. <templateHead6 v-if="skinId==6"></templateHead6>
  8. <!-- 菜单 -->
  9. <templateMenu v-if="skinId<=4"></templateMenu>
  10. <!-- 皮肤5菜单 -->
  11. <templateMenu5 v-if="skinId>=5"></templateMenu5>
  12. <!-- 内容 -->
  13. <div v-for="(item,index) in templateData" :key="index">
  14. <!--1.频道菜单-->
  15. <div v-if="item.sectorName=='channelMenu'">
  16. <templateChannelMenu :skinId="skinId" :routeId="routeId" :navigateData="navigateData.data" :templateData="item.componentList"></templateChannelMenu>
  17. </div>
  18. <!--2.广告组件-->
  19. <div v-if="item.sectorName=='adSector'">
  20. <templateAd :skinId="skinId" :adData="adData" :adTag="item.ad.ad_tag" ></templateAd>
  21. </div>
  22. <!--3.滚动图文组合-->
  23. <div v-if="item.sectorName=='scrollTextSector'">
  24. <templateScrollList :skinId="skinId" :templateData="item.componentList"></templateScrollList>
  25. </div>
  26. <!--4.图文组合1-->
  27. <div v-if="item.sectorName=='manyPictureSector'">
  28. <templateNewSector1 :skinId="skinId" :templateData="item.componentList"></templateNewSector1>
  29. </div>
  30. <!--5.图文组合2-->
  31. <div v-if="item.sectorName=='commentSector'">
  32. <templateNewSector2 :skinId="skinId" :templateData="item.componentList"></templateNewSector2>
  33. </div>
  34. <!--6.图文组合3-->
  35. <div v-if="item.sectorName=='listSector'">
  36. <templateNewSector3 :skinId="skinId" :templateData="item.componentList"></templateNewSector3>
  37. </div>
  38. <!-- 7.带标题的图文组合 -->
  39. <div v-if="item.sectorName=='channelNewsSector'">
  40. <templateNewSector4 :skinId="skinId" :templateData="item.componentList"></templateNewSector4>
  41. </div>
  42. <!-- 8.不带标题的图文组合 -->
  43. <div v-if="item.sectorName=='newsPhotoSector'">
  44. <templateNewPhotoSector :skinId="skinId" :templateData="item.componentList"></templateNewPhotoSector>
  45. </div>
  46. <!-- 9.带标题的文字新闻通栏 -->
  47. <div v-if="item.sectorName=='channelTextSector'">
  48. <templateNewTextSector :skinId="skinId" :templateData="item.componentList"></templateNewTextSector>
  49. </div>
  50. <!-- 10.不带标题的图文组合 -->
  51. <div v-if="item.sectorName=='newListPhotoSector'">
  52. <templateNewListPhotoSector :skinId="skinId" :templateData="item.componentList"></templateNewListPhotoSector>
  53. </div>
  54. <!-- 11.皮肤6 带标题图文组合 -->
  55. <div v-if="item.sectorName=='ChannelNewsPhotoSector'">
  56. <templateChannelNewsPhotoSector :skinId="skinId" :templateData="item.componentList"></templateChannelNewsPhotoSector>
  57. </div>
  58. <!-- 12.皮肤6 不带标题图文组合1 -->
  59. <div v-if="item.sectorName=='ChannelNewsSector'">
  60. <templateChannelNewsSector :skinId="skinId" :templateData="item.componentList"></templateChannelNewsSector>
  61. </div>
  62. <!-- 13.皮肤6 带标题图文组合2 -->
  63. <div v-if="item.sectorName=='ChannelNewsPhoto'">
  64. <templateChannelNewsPhoto :skinId="skinId" :templateData="item.componentList"></templateChannelNewsPhoto>
  65. </div>
  66. <!-- 14.皮肤6 不带标题图文组合2 -->
  67. <div v-if="item.sectorName=='ChannelNewsAndPhoto'">
  68. <templateChannelNewsAndPhoto :skinId="skinId" :templateData="item.componentList"></templateChannelNewsAndPhoto>
  69. </div>
  70. </div>
  71. <!-- 底部 -->
  72. <templateFoot v-if="skinId<=4"></templateFoot>
  73. <!-- 皮肤5底部 -->
  74. <templateFoot1 v-if="skinId>=5"></templateFoot1>
  75. </template>
  76. <script setup lang="ts">
  77. //0.加载全局模板组件 start---------------------------------------->
  78. //0.1全局通栏
  79. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  80. import templateHead5 from '@/components/template/sector/head/1200x250/1.vue'
  81. import templateHead6 from '@/components/template/sector/head/1200x250/6.vue'
  82. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  83. import templateMenu5 from '@/components/template/sector/menu/1200x187/1.vue'
  84. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  85. import templateFoot1 from '@/components/template/sector/foot/1200x680/1.vue'
  86. //0.2局部通栏
  87. //0.2.1广告组件
  88. import templateAd from '@/components/template/sector/body/ad/1200x90/1.vue'
  89. //0.2.2 频道菜单
  90. import templateChannelMenu from '@/components/template/sector/body/class/menu/1200x100/1.vue'
  91. //0.2.3 滚动图文组合
  92. import templateScrollList from '@/components/template/sector/body/class/banner/1200x410/1.vue'
  93. //0.2.3 图文组合1
  94. import templateNewSector1 from '@/components/template/sector/body/index/list/1200x470/1.vue'
  95. //0.2.4 图文组合2
  96. import templateNewSector2 from '@/components/template/sector/body/index/list/1200x470/2.vue'
  97. //0.2.5 图文组合3
  98. import templateNewSector3 from '@/components/template/sector/body/index/list/1200x980/1.vue'
  99. //0.2.6 带标题的图文组合
  100. import templateNewSector4 from '@/components/template/sector/body/index/list/1200x600/1.vue'
  101. //0.2.7 不带标题的图文组合
  102. import templateNewPhotoSector from '@/components/template/sector/body/index/list/1200x430/1.vue'
  103. //0.2.8 带标题的文字新闻通栏
  104. import templateNewTextSector from '@/components/template/sector/body/index/list/1200x500/1.vue'
  105. //0.2.9 不带标题的图文组合
  106. import templateNewListPhotoSector from '@/components/template/sector/body/index/list/1200x500/2.vue'
  107. // 0.2.10 皮肤6 带标题图文组合
  108. import templateChannelNewsPhotoSector from '~/components/template/sector/body/index/list/1200x430/6/3.vue'
  109. // 0.2.11 皮肤6 不带标题图文组合2
  110. import templateChannelNewsSector from '~/components/template/sector/body/index/list/1200x330/6/1.vue'
  111. // 0.2.12 皮肤6 带标题图文组合2
  112. import templateChannelNewsPhoto from '~/components/template/sector/body/index/list/1200x400/6/1.vue'
  113. // 0.2.13 皮肤6 不带标题图文组合2
  114. import templateChannelNewsAndPhoto from '~/components/template/sector/body/index/list/1200x480/6/3.vue'
  115. //0.加载全局模板组件 end---------------------------------------->
  116. //1.获得基本信息单元 start---------------------------------------->
  117. //1.1获得页面依赖
  118. import { ref, onMounted } from 'vue';
  119. import { ElMessage } from 'element-plus';
  120. //1.2使用url查询导航池id
  121. const targetSegment = getRoutePath(1);
  122. const routeId = ref<number>(0);
  123. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  124. method: 'GET',
  125. query: {
  126. 'pinyin': targetSegment,
  127. },
  128. });
  129. if (getRouteId.code == 200) {
  130. routeId.value = getRouteId.data.category_id
  131. }
  132. //1.4获得pinia源
  133. import { useTemplateBaseStore } from '@/stores/templateBase'
  134. const templateBaseStore:any = useTemplateBaseStore()
  135. //1.5获得该页的皮肤id - 在每个组件中也是同样的获得方法
  136. const skinId = ref<number>(0)
  137. const websiteId = ref<number>(0)
  138. //1.6获得站点基本信息
  139. const responseStatus = await requestDataPromise('/web/getWebsiteAllinfo', {
  140. method: 'GET',
  141. query: {
  142. 'link_textnum':24,
  143. 'link_imgnum':18,
  144. 'link_footnum':4
  145. },
  146. });
  147. if (responseStatus.code == 200) {
  148. if(responseStatus.data.website_foot.foot_info.status == 1){
  149. //网站模板已停用,直接转入404页面
  150. navigateTo('/error?findPage=index')
  151. }else{
  152. //1.6.1设置站点基本信息
  153. templateBaseStore.setWebSiteInfo(responseStatus.data)
  154. websiteId.value = responseStatus.data.website_head.id;//获得网站id
  155. //1.6.2设置皮肤id
  156. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  157. }
  158. }
  159. //1.7.seo
  160. const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
  161. method: 'GET',
  162. query: {
  163. 'catid': routeId.value
  164. },
  165. });
  166. let seoTitle = setData.data.seo_title;
  167. let seoDescription = setData.data.seo_description;
  168. let seoKeywords = setData.data.seo_keywords;
  169. let seoSuffix = setData.data.suffix;
  170. let seoName = setData.data.website_name;
  171. useHead({
  172. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  173. meta: [
  174. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  175. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  176. ]
  177. });
  178. //1.获得基本信息单元 end---------------------------------------->
  179. //2.页面数据 start---------------------------------------->
  180. //2.1预创建请求数据
  181. const templateGetData:any = [
  182. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0},
  183. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0},
  184. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0},
  185. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0},
  186. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0},
  187. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0},
  188. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0},
  189. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0},
  190. {"parent":routeId.value+",0,0","child":"","imgnum":0,"textnum":0}
  191. ]
  192. //2.2获得模板数据
  193. const response:any = await requestDataPromise('/client/indexData', {
  194. method: 'POST',
  195. body: {
  196. 'website_id':websiteId.value,
  197. 'getpage':'class'
  198. },
  199. });
  200. const templateData = response.data.template.class;
  201. //是否启用搜索功能
  202. templateBaseStore.setIsSearch(response.data.isSearch)
  203. console.log('templateData111111111',templateData)
  204. //2.2.1循环一下模板数据,把所有需要请求后端内容的组件里面imgSize和textSize拿出来
  205. const getIndex = ref<number>(0);
  206. for(let item of templateData){
  207. if(item.sectorName == 'scrollTextSector'||item.sectorName == 'manyPictureSector'||item.sectorName == 'commentSector'||item.sectorName == 'listSector' || item.sectorName == 'channelNewsSector' || item.sectorName == 'newsPhotoSector' || item.sectorName == 'channelTextSector' || item.sectorName == 'newListPhotoSector' || item.sectorName == 'ChannelNewsPhotoSector' || item.sectorName == 'ChannelNewsSector' || item.sectorName == 'ChannelNewsPhoto' || item.sectorName == 'ChannelNewsAndPhoto' ){
  208. for(let i of item.componentList){
  209. templateGetData[getIndex.value].imgnum = i.componentData.imgSize;
  210. templateGetData[getIndex.value].textnum = i.componentData.textSize;
  211. getIndex.value++;
  212. }
  213. }
  214. }
  215. //2.3 获得导航数据
  216. const navigateData = await requestDataPromise('/web/getWebsiteModelCategory', {
  217. method: 'GET',
  218. query: {
  219. 'placeid': 1,
  220. 'pid': routeId.value,
  221. 'num': 8
  222. },
  223. });
  224. const getNavIndex = ref<number>(0);
  225. for(let item of navigateData.data){
  226. templateGetData[getNavIndex.value].child = item.category_id;
  227. getNavIndex.value++;
  228. }
  229. //获得完整的请求数据
  230. const jsonString = JSON.stringify(getTransformArray(templateGetData));
  231. //2.4获得页面完整的请求数据
  232. const mkdata = await requestDataPromise('/web/getWebsiteAllArticle', {
  233. method: 'GET',
  234. query: {
  235. 'id': jsonString
  236. },
  237. });
  238. if (mkdata.code == 200) {
  239. //获得所有子频道的内容
  240. let childData = ref<any>([]);
  241. for(let item of mkdata.data){
  242. childData.value.push(item.child)
  243. }
  244. let dataSort = ref<number>(0);
  245. const childDataLength = childData.value.length;
  246. //如果当前循环的这个组件数据长度已经超过了所有子频道的总数居量,则从0开始循环
  247. //此操作是为了防止B端创建的组件数超过了后台的导航数量
  248. for(let item of templateData){
  249. if(item.sectorName == 'scrollTextSector'){
  250. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  251. dataSort.value++;
  252. }
  253. if(item.sectorName == 'manyPictureSector'){
  254. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  255. dataSort.value++;
  256. item.componentList[1].componentData.data = childData.value[dataSort.value % childDataLength];
  257. dataSort.value++;
  258. }
  259. if(item.sectorName == 'commentSector'){
  260. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  261. dataSort.value++;
  262. item.componentList[1].componentData.data = childData.value[dataSort.value % childDataLength];
  263. dataSort.value++;
  264. }
  265. if(item.sectorName == 'listSector'){
  266. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  267. dataSort.value++;
  268. item.componentList[1].componentData.data = childData.value[dataSort.value % childDataLength];
  269. dataSort.value++;
  270. item.componentList[2].componentData.data = childData.value[dataSort.value % childDataLength];
  271. dataSort.value++;
  272. }
  273. if(item.sectorName == 'channelNewsSector'){
  274. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  275. dataSort.value++;
  276. item.componentList[1].componentData.data = childData.value[dataSort.value % childDataLength];
  277. dataSort.value++;
  278. }
  279. if(item.sectorName == 'newsPhotoSector'){
  280. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  281. dataSort.value++;
  282. }
  283. if(item.sectorName == 'channelTextSector'){
  284. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  285. dataSort.value++;
  286. item.componentList[1].componentData.data = childData.value[dataSort.value % childDataLength];
  287. dataSort.value++;
  288. }
  289. if(item.sectorName == 'newListPhotoSector'){
  290. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  291. dataSort.value++;
  292. item.componentList[1].componentData.data = childData.value[dataSort.value % childDataLength];
  293. dataSort.value++;
  294. }
  295. if(item.sectorName == 'ChannelNewsPhotoSector'){
  296. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  297. dataSort.value++;
  298. item.componentList[1].componentData.data = childData.value[dataSort.value % childDataLength];
  299. dataSort.value++;
  300. }
  301. if(item.sectorName == 'ChannelNewsSector'){
  302. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  303. dataSort.value++;
  304. }
  305. if(item.sectorName == 'ChannelNewsPhoto'){
  306. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  307. dataSort.value++;
  308. item.componentList[1].componentData.data = childData.value[dataSort.value % childDataLength];
  309. dataSort.value++;
  310. item.componentList[2].componentData.data = childData.value[dataSort.value % childDataLength];
  311. dataSort.value++;
  312. }
  313. if(item.sectorName == 'ChannelNewsAndPhoto'){
  314. item.componentList[0].componentData.data = childData.value[dataSort.value % childDataLength];
  315. dataSort.value++;
  316. }
  317. }
  318. //console.log(templateData)
  319. }
  320. //2.5广告数据
  321. const adData:any = ref([]);
  322. adData.value.push(response.data.ad.top)
  323. for(let item of response.data.ad.class){
  324. adData.value.push(item)
  325. }
  326. templateBaseStore.setAdList(adData.value)
  327. //2.页面数据 end---------------------------------------->
  328. </script>
  329. <style lang="less" scoped>
  330. @import '@/assets/css/class.less';
  331. </style>